using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.Common;
using Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.Common.DataSets;
using System.Configuration;


namespace Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.Business
{
	/// <summary>
    /// Provides Business Logic for System Adapters Reference Data.
	/// </summary>
    public class RefDataManager
	{
		/// <summary>
		/// Load the package of Reference data needed by System Adapters.
		/// </summary>
		/// <returns>Returns an object representing the reference data package.</returns>
        public static ReferenceData GetRefData()
		{
			ReferenceData refData = new ReferenceData();

			dvRefData dv = DataAccess.RefData.GetRefData();

			refData.MessageStatuses = new List<MessageStatus>();

			foreach(dvRefData.PnPMessageStatusRow dr in dv.PnPMessageStatus)
				refData.MessageStatuses.Add(new MessageStatus(dr.messageStatusID, dr.displayName, dr.canBeSetBy));

			refData.MessageTypes = new List<MessageType>();

			foreach (dvRefData.MessageTypeRow dr in dv.MessageType)
				refData.MessageTypes.Add(new MessageType(dr.messageTypeID, dr.description, dr.xmlSchema, dr.version));

			refData.ServiceProviderTypes = new List<ServiceProviderType>();

			foreach (dvRefData.ServiceProviderTypeRow dr in dv.ServiceProviderType)
				refData.ServiceProviderTypes.Add(new ServiceProviderType(dr.serviceProviderTypeID, dr.displayName, dr.serviceProviderTypeCode));

			return refData;
		}

	}
}
